﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>质控项编辑</title>
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/ligerui-icons.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Gray/css/all.css" />
    <link rel="stylesheet" href="~/Content/css/common.css" />
    <script src="~/Scripts/jquery-1.10.2.min.js"  ></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <style>
        .gridtable {
            width: 100%;
            margin: 0px;
        }

            .gridtable td {
                height: 30px;
                line-height: 30px;
            }
    </style>
</head>
<body>
    <div style="margin:10px 0px;">
        <table class="gridtable">
            <tr>
                <td style="text-align:right; width:100px;">
                    质控名称：
                </td>
                <td>
                    <input type="text" id="txtTitle" class="l-text" style="width:250px;" />
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    质控项：
                </td>
                <td>
                    <select id="selQualityPointTCId" name="QualityPointTCId"></select>
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    比对项：
                </td>
                <td>
                    <select id="selComparePointTCId" name="ComparePointTCId"></select>
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    超时时长：
                </td>
                <td>
                    <input type="number" class="l-text" style="width:50px;" id="txtOverTime" />分钟
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    是否启用：
                </td>
                <td>

                    <input type="radio" id="txtStatus1" name="Status" class="l-radio" title="是" value="1" />是&nbsp;&nbsp;<input type="radio" id="txtStatus0" class="l-radio" name="Status" title="否" value="0" />否
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    排序：
                </td>
                <td>
                    <input type="text" id="txtSort" name="Sort" style="width:50px;" class="l-text" />
                </td>
            </tr>
            @*<tr>
                    <td style="text-align:right; width:100px;">
                        备注：
                    </td>
                    <td style="padding-top: 5px;">
                        <textarea id="txtRemarks" rows="3" class="l-textarea" maxlength="500" style="padding:5px;width:240px;"></textarea>
                    </td>
                </tr>*@
            <tr>
                <td colspan="2" style="text-align:center;padding-top:10px;">
                    <input id="btnSubmit" type="button" value="保存" class="l-button" style="background: skyblue;" onclick="save()" />&nbsp;&nbsp;&nbsp;
                    <input id="btnCancel" type="button" value="取消" class="l-button" onclick="closeDialog()" />
                </td>
            </tr>
            <tr></tr>
        </table>
        <input type="hidden" id="txtId" />
    </div>
    <script  >
        $(function () {
            setValue();
            setTimeout(function () {
                $(".l-dialog-winbtn .l-dialog-close").click(function () {
                    parent.window.location.reload();
                });
            }, 1000);
        });
        //获取修改数据
        function setValue() {
            $.ajax({
                url: '/ChestPainCenter/QualityPoint/GetDataById?Id=' + "@ViewBag.Id" + '&ram=' + Math.random(),
                cache: false,
                success: function (data) {
                    var rows = eval(data);
                    if (rows.length > 0) {
                        var row = rows[0];
                        $('#txtId').val(row.Id);
                        $('#txtTitle').val(row.Title);
                        $('#txtOverTime').val(row.OverTime);
                        $('#txtStatus' + row.Status).attr('checked', 'checked');
                        $('#txtSort').val(row.Sort);
                        GetAllPoint('selQualityPointTCId', row.QualityPointTCId);
                        GetAllPoint('selComparePointTCId', row.ComparePointTCId);
                    } else {
                        GetAllPoint('selQualityPointTCId');
                        GetAllPoint('selComparePointTCId');
                    }
                }
            });
        }
        //关闭弹框
        function closeDialog() {
            parent.window.location.reload();
            frameElement.dialog.close();//关闭dialog
        }
        //保存
        function save() {
            if ($("#txtPathWayName").val() == "")
            { $("#txtPathWayName").focus(); return; }
            var editurl = "../QualityPoint/EditSubmit";
            $.post(editurl, {
                rnd: new Date().getMilliseconds(),
                QualityPointTCId: $("#selQualityPointTCId").val(),
                QualityPointTitle: $("#selQualityPointTCId").find("option:selected").text(),
                QualityPointTableName: $("#selQualityPointTCId").find("option:selected").attr('data-table'),
                QualityPointName: $("#selQualityPointTCId").find("option:selected").attr('data-column'),
                ComparePointTCId: $("#selComparePointTCId").val(),
                ComparePointTitle: $("#selComparePointTCId").find("option:selected").text(),
                ComparePointTableName: $("#selComparePointTCId").find("option:selected").attr('data-table'),
                ComparePointName: $("#selComparePointTCId").find("option:selected").attr('data-column'),
                OverTime: $("#txtOverTime").val(),
                Title: $("#txtTitle").val(),
                Sort: $("#txtSort").val(),
                Status: $("input[name='Status']:checked").val(),
                Id: $("#txtId").val()
            }, function (data) {
                $.ligerDialog.alert(data);
                closeDialog();
            })
        }
        //获取下拉框数据
        function GetAllPoint(selid, value) {
            $.ajax({
                url: '/ChestPainCenter/QualityPoint/GetTableColumnList?ram=' + Math.random(),
                cache: false,
                success: function (data) {
                    var jsonData = $.parseJSON(data);
                    var strVar = "<option value='0'></option>";
                    $.each(jsonData, function (i, a) {
                        strVar += '<option value="' + a.Id + '" data-table="' + a.TableName + '" data-column="' + a.ColumnName + '">' + a.Name + '</option>'
                    })
                    $("#" + selid).html(strVar);
                    if (value) {
                        $("#" + selid).val(value);
                    }
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }
</script>
</body>
</html>
